﻿// ....................................................................................................................
//	Author: Copyright (C) 2012 Ing. Marek Hubal
//	Email: hubal@acasoftware.org
// ....................................................................................................................

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Security.Permissions;

namespace core
{
    /// <summary>Trieda IShellContextMenu</summary>
	public class IShellContextMenu
	{
        [System.Runtime.InteropServices.DllImport("core2.dll", CallingConvention=System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern void ShowShellContextMenu(IntPtr pHandle, string pItems, int pX, int pY);
        [System.Runtime.InteropServices.DllImport("core2.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern void ExecuteShellCommand(IntPtr pHandle, string pItems, string pCommand);
        [System.Runtime.InteropServices.DllImport("core2.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern void ShowItemPropertyWindow(IntPtr pHandle, string pItems);
        [System.Runtime.InteropServices.DllImport("core2.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern void ShowAdvancedShareWindow(IntPtr pHandle, string pItem);

        /// <summary>Zobrazenie content menu pre zadane polozky</summary>
        /// <param name="pHandle">handle okna</param>
        /// <param name="pItems">zoznam objektov</param>
        /// <param name="pX">X pozicia menu</param>
        /// <param name="pY">Y pozicia menu</param>
        public static void InvokeShowShellContextMenu(IntPtr pHandle, System.Collections.Generic.List<string> pItems, int pX = -1, int pY = -1)
        {
            string S = ICore.StringList2String(pItems, ((char)0x1).ToString()); // Prevediem na retazec
            ShowShellContextMenu(pHandle, S, pX, pY); // Volam zobrazenie menu
        }
        /// <summary>Zobrazenie content menu pre zadane polozky</summary>
        /// <param name="pHandle">handle okna</param>
        /// <param name="pItems">zoznam objektov</param>
        /// <param name="pCommand"></param>
        public static void InvokeExecuteShellCommand(IntPtr pHandle, System.Collections.Generic.List<string> pItems, string pCommand)
        {
            string S = ICore.StringList2String(pItems, ((char)0x1).ToString()); // Prevediem na retazec
            ExecuteShellCommand(pHandle, S, pCommand); // Volam zobrazenie menu
        }
        /// <summary>Zobrazenie content menu pre zadane polozky</summary>
        /// <param name="pHandle">handle okna</param>
        /// <param name="pItems">zoznam objektov</param>
        /// <param name="pCommand"></param>
        public static void InvokeShowItemPropertyWindow(IntPtr pHandle, string pName)
        {
            ShowItemPropertyWindow(pHandle, pName); // Volam zobrazenie menu
        }
        /// <summary>Zobrazenie content menu pre zadane polozky</summary>
        /// <param name="pHandle">handle okna</param>
        /// <param name="pItems">zoznam objektov</param>
        /// <param name="pCommand"></param>
        public static void InvokeShowAdvancedShareWindow(IntPtr pHandle, string pName)
        {
            ShowAdvancedShareWindow(pHandle, pName); // Volam zobrazenie menu
        }
    }
}
